package algorithm.poj.p1000;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLDecoder;
import java.util.StringTokenizer;

public class P1797 {

	@SuppressWarnings("unchecked")
	public static void main(String[] args) throws Exception {

		InputStream input = null;
		if (false) {
			input = System.in;
		} else {
			URL url = P1797.class.getResource("P1797.txt");
			File file = new File(URLDecoder.decode(url.getPath(), "UTF-8"));
			input = new FileInputStream(file);
		}
		
		BufferedReader stdin = new BufferedReader(new InputStreamReader(input));

		StringTokenizer st = null;
		String line = stdin.readLine();
		int N = Integer.valueOf(line);
		for (int i = 0; i < N; i ++) {
			st = new StringTokenizer(stdin.readLine());
			int n = Integer.valueOf(st.nextToken());
			int m = Integer.valueOf(st.nextToken());
			int w = -1;
			Edge[] edges = new Edge[m];
			for (int j = 0; j < m; j ++) {
				st = new StringTokenizer(stdin.readLine());
				edges[j] = new Edge();
				edges[j].u = Integer.valueOf(st.nextToken())-1;
				edges[j].v = Integer.valueOf(st.nextToken())-1;
				edges[j].weight = Integer.valueOf(st.nextToken());
			}
			System.out.println("Scenario #" + (i+1) + ":\n" + w +"\n");
		}
	}
	
	private static class Edge {
		int u;
		int v;
		int weight;
	}
}